package change;

public class change {
    public static void main(String[] args) {
        String str = "A dog is a kind of animal";
        StringBuffer sb = new StringBuffer(str);
        int index = sb.indexOf("dog");
        if (index != -1) {
            sb.replace(index, index + "dog".length(), "cat");
        }
        System.out.println(sb.toString());
    }
}
